package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 添加菜品
     * @param dish
     */
    void add(Dish dish);

    /**
     * 菜品分页查询
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> pqgeQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 查询起售菜品数量
     * @param ids
     * @return
     */
    Integer countStartDishNum(List<Long> ids);

    /**
     * 批量删除
     * @param ids
     */
    void deletBatch(List<Long> ids);

    /**
     * 根据id查询菜品信息
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    /**
     * 查询DishVO
     * @param id
     * @return
     */
    DishVO getDishVO(Long id);

    void update(Dish dish);

    List<Dish> list(Dish dish);

    /**
     * 根据套餐id查询菜品
     * @param id
     * @return
     */
    @Select("select a.* from dish a left join setmeal_dish sd on a.id = sd.dish_id where setmeal_id = #{setmealId}")
    List<Dish> getBySetmealId(Long id);

    /**
     * 查询dishVolist
     * @param dish
     * @return
     */
    List<DishVO> getDishVOList(Dish dish);
}
